/*
 * @Author: your name
 * @Date: 2021-12-28 11:22:19
 * @LastEditTime: 2022-05-18 10:31:34
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /medical-plugin-dvp/utils/util.js
 */
const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}
const postRequest = (url,data) => {
  return new Promise((resolve, reject) => {
    wx.request({
      url,
      data,
      header: {
      'content-type': 'application/x-www-form-urlencoded'
    },
      method: 'POST',
      success: function(res){
        resolve(res);
      },
      fail: function(err) {
        reject(err);
      }
    })
  })
}

// --------------------------------测试环境的--------------------------------
// // 图片目录
// export const imgBaseUrl = 'https://testyjt.lianjieit.net/gf/mg/'
// // 接口地址
// export const requestUrl = 'https://testyjt.lianjieit.net/gf/api_miniprogram/'
// // 新增接口地址--视频接口
// export const requestNewUrlVideo = 'https://testyjt.lianjieit.net/gf/api_miniprogram/video/'
// // 新增接口地址--图文接口
// export const requestNewUrlChat = 'https://testyjt.lianjieit.net/gf/api_miniprogram/chat/'
// // 新增接口地址--用户优化信息校验
// export const requestNewUrlUserConfirm = 'https://testyjt.lianjieit.net/gf/api_miniprogram/check/'
// // 上传图片接口
// export const requestUploadImages = "https://testyjt.lianjieit.net/gf/api_miniprogram/api_system/upload_img" 
// // 新增-药房图片地址
// const pharmacyImgURL = 'https://testyjt.lianjieit.net/gf/mg/pharmacyImages/'

// --------以下是 正式环境请求地址--------
// 图片目录
// export const imgBaseUrl = 'https://www.lianjieit.net/gf/mg/'
// // 接口地址
// export const requestUrl = 'https://www.lianjieit.net/gf/api_miniprogram/'
// // 新增接口地址--视频接口
// export const requestNewUrlVideo = 'https://www.lianjieit.net/gf/api_miniprogram/video/'
// // 新增接口地址--图文接口
// export const requestNewUrlChat = 'https://www.lianjieit.net/gf/api_miniprogram/chat/'
// // 新增接口地址--用户优化信息校验
// export const requestNewUrlUserConfirm = 'https://www.lianjieit.net/gf/api_miniprogram/check/'
// // 上传图片接口
// export const requestUploadImages = "https://www.lianjieit.net/gf/api_miniprogram/api_system/upload_img" 
// // 新增-药房图片地址
// const pharmacyImgURL = 'https://www.lianjieit.net/gf/mg/pharmacyImages/'



// 图片目录
const imgBaseUrl = 'https://dvp.lianjieit.net/his_dvp/mg/'
// 接口地址
const requestUrl = 'https://dvp.lianjieit.net/his_dvp/api_miniprogram/'
// 新增接口地址--视频接口
const requestNewUrlVideo = 'https://dvp.lianjieit.net/his_dvp/api_miniprogram/video/'
// 新增接口地址--图文接口
const requestNewUrlChat = 'https://dvp.lianjieit.net/his_dvp/api_miniprogram/chat/'
const requestNewUrlUserConfirm = 'https://dvp.lianjieit.net/his_dvp/api_miniprogram/check/'
const requestUploadImages = "https://dvp.lianjieit.net/his_dvp/api_miniprogram/api_system/upload_img"
// 新增-药房图片地址
const pharmacyImgURL = 'https://dvp.lianjieit.net/his_dvp/mg/pharmacyImages/'

module.exports = {
  formatTime,
  postRequest,
  imgBaseUrl,
  requestUrl,
  requestNewUrlVideo,
  requestNewUrlChat,
  requestNewUrlUserConfirm,
  requestUploadImages,
  pharmacyImgURL,
  getGlobalData: () => {
    return getApp().globalData;
}
}
